﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.ComponentModel;
using Taurus.Parking.DTO;

namespace Taurus.Parking.CarPropertyBind
{
    public class CarTypeDescriptionProvider : TypeDescriptionProvider
    {
        private ICustomTypeDescriptor td;

        public CarTypeDescriptionProvider()
            : this(TypeDescriptor.GetProvider(typeof(Car)))
        { }

        public CarTypeDescriptionProvider(TypeDescriptionProvider parent)
            : base(parent)
        { }

        public override ICustomTypeDescriptor GetTypeDescriptor(Type objectType, object instance)
        {
            if (td == null)
            {
                td = base.GetTypeDescriptor(objectType, instance);
                td = new CarCustomTypeDescriptor(td);
            }
            return td;
        }
    }
}
